package com.stagewebserver.webserver.controller;

import com.stagecommon.common.pojo.Category;
import com.stagecommon.common.pojo.RespBean;
import com.stagecommon.common.vo.CategoryVo;
import com.stagewebserver.webserver.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: yxl
 * @since: 2021-11-22
 **/
@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    //所有分类
    @GetMapping("/categoryList")
    public RespBean listCategory(){
        return categoryService.listCategories();
    }

    //一级分类新作
    @GetMapping("/categoryNewList")
    public RespBean listCategoryNewList(){
        return categoryService.listNewFistLevelCategories();
    }

    //一级分类热门
    @GetMapping("/categoryHotList")
    public RespBean listCategoryHotList(){
        return categoryService.listHotFirstLevelCategories();
    }

    //二级分类
    @GetMapping("/listSecondLevelCategories")
    public RespBean listSecondLevelCategories(){
        return categoryService.listSecondCategories();
    }

    /**
     * 获取所有分类
     * @param currentPage
     * @param size
     * @param category
     * @return
     */
    @GetMapping("/getAllCategory")
    public RespBean getAllCategory(@RequestParam(defaultValue = "1") Integer currentPage,
                                   @RequestParam(defaultValue = "10") Integer size,
                                   Category category){
        return categoryService.getAllCategory(currentPage, size, category);
    }
}
